

package com.click.app.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 *
 * @author ariel
 */
@Entity
@Table(name = "asignation_cut_pays")
public class AsignationCutPay extends BaseObject{

    private static final long serialVersionUID = 1L;
    
    private Long id;
    private Double amountPayed;
    private CutProcess cutProcess;
    private PaymentsCut paymentsCut;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name="id_asignation_cut_pay", unique=true, nullable=false)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "amount_payed", precision = 6, scale = 0)
    public Double getAmountPayed() {
        return amountPayed;
    }

    public void setAmountPayed(Double amountPayed) {
        this.amountPayed = amountPayed;
    }

    @JoinColumn(name = "id_cut_process", referencedColumnName = "id_cut_process")
    @ManyToOne(optional = false)
    public CutProcess getCutProcess() {
        return cutProcess;
    }

    public void setCutProcess(CutProcess cutProcess) {
        this.cutProcess = cutProcess;
    }

    @JoinColumn(name = "id_payments_cut", referencedColumnName = "id_payments_cut")
    @ManyToOne(optional = false)
    public PaymentsCut getPaymentsCut() {
        return paymentsCut;
    }

    public void setPaymentsCut(PaymentsCut paymentsCut) {
        this.paymentsCut = paymentsCut;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (getId() != null ? getId().hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AsignationCutPay)) {
            return false;
        }
        AsignationCutPay other = (AsignationCutPay) object;
        if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE)
                    .append(this.id).append(this.amountPayed).append(this.cutProcess.getId())
                    .append(this.paymentsCut.getId()).toString();
    }

}
